home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / NCP_FS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  7KB  |  302 lines

  1. /*
  2.  *  ncp_fs.h
  3.  *
  4.  *  Copyright (C) 1995, 1996 by Volker Lendecke
  5.  *
  6.  */
  7.  
  8. #ifndef _LINUX_NCP_FS_H
  9. #define _LINUX_NCP_FS_H
  10.  
  11. #include <linux/fs.h>
  12. #include <linux/in.h>
  13. #include <linux/types.h>
  14.  
  15. #include <linux/ncp_mount.h>
  16. #include <linux/ncp_fs_sb.h>
  17. #include <linux/ncp_fs_i.h>
  18.  
  19. /*
  20.  * ioctl commands
  21.  */
  22.  
  23. struct ncp_ioctl_request {
  24.     unsigned int function;
  25.     unsigned int size;
  26.     char *data;
  27. };
  28.  
  29. struct ncp_fs_info {
  30.     int version;
  31.     struct sockaddr_ipx addr;
  32.     __kernel_uid_t mounted_uid;
  33.     int connection;        /* Connection number the server assigned us */
  34.     int buffer_size;    /* The negotiated buffer size, to be
  35.                    used for read/write requests! */
  36.  
  37.     int volume_number;
  38.     __u32 directory_id;
  39. };
  40.  
  41. struct ncp_sign_init
  42. {
  43.     char sign_root[8];
  44.     char sign_last[16];
  45. };
  46.  
  47. struct ncp_lock_ioctl
  48. {
  49. #define NCP_LOCK_LOG    0
  50. #define NCP_LOCK_SH    1
  51. #define NCP_LOCK_EX    2
  52. #define NCP_LOCK_CLEAR    256
  53.     int        cmd;
  54.     int        origin;
  55.     unsigned int    offset;
  56.     unsigned int    length;
  57. #define NCP_LOCK_DEFAULT_TIMEOUT    18
  58. #define NCP_LOCK_MAX_TIMEOUT        180
  59.     int        timeout;
  60. };
  61.  
  62. struct ncp_setroot_ioctl
  63. {
  64.     int        volNumber;
  65.     int        namespace;
  66.     __u32        dirEntNum;
  67. };
  68.  
  69. struct ncp_objectname_ioctl
  70. {
  71. #define NCP_AUTH_NONE    0x00
  72. #define NCP_AUTH_BIND    0x31
  73. #define NCP_AUTH_NDS    0x32
  74.     int        auth_type;
  75.     size_t        object_name_len;
  76.     void*        object_name;    /* an userspace data, in most cases user name */
  77. };
  78.  
  79. struct ncp_privatedata_ioctl
  80. {
  81.     size_t        len;
  82.     void*        data;        /* ~1000 for NDS */
  83. };
  84.  
  85. #define    NCP_IOC_NCPREQUEST        _IOR('n', 1, struct ncp_ioctl_request)
  86. #define    NCP_IOC_GETMOUNTUID        _IOW('n', 2, __kernel_uid_t)
  87.  
  88. #if 1
  89. #ifdef __KERNEL__
  90. /* remove after ncpfs-2.0.13 gets released or at the beginning of kernel-2.1. codefreeze */
  91. #define    NCP_IOC_GETMOUNTUID_INT        _IOW('n', 2, unsigned int)
  92. #endif
  93. #endif
  94.  
  95. #define NCP_IOC_CONN_LOGGED_IN          _IO('n', 3)
  96.  
  97. #define NCP_GET_FS_INFO_VERSION (1)
  98. #define NCP_IOC_GET_FS_INFO             _IOWR('n', 4, struct ncp_fs_info)
  99.  
  100. #define NCP_IOC_SIGN_INIT        _IOR('n', 5, struct ncp_sign_init)
  101. #define NCP_IOC_SIGN_WANTED        _IOR('n', 6, int)
  102. #define NCP_IOC_SET_SIGN_WANTED        _IOW('n', 6, int)
  103.  
  104. #define NCP_IOC_LOCKUNLOCK        _IOR('n', 7, struct ncp_lock_ioctl)
  105.  
  106. #define NCP_IOC_GETROOT            _IOW('n', 8, struct ncp_setroot_ioctl)
  107. #define NCP_IOC_SETROOT            _IOR('n', 8, struct ncp_setroot_ioctl)
  108.  
  109. #define NCP_IOC_GETOBJECTNAME        _IOWR('n', 9, struct ncp_objectname_ioctl)
  110. #define NCP_IOC_SETOBJECTNAME        _IOR('n', 9, struct ncp_objectname_ioctl)
  111. #define NCP_IOC_GETPRIVATEDATA        _IOWR('n', 10, struct ncp_privatedata_ioctl)
  112. #define NCP_IOC_SETPRIVATEDATA        _IOR('n', 10, struct ncp_privatedata_ioctl)
  113.  
  114. /*
  115.  * The packet size to allocate. One page should be enough.
  116.  */
  117. #define NCP_PACKET_SIZE 4070
  118.  
  119. #define NCP_MAXPATHLEN 255
  120. #define NCP_MAXNAMELEN 14
  121.  
  122. #ifdef __KERNEL__
  123.  
  124. #include <linux/config.h>
  125.  
  126. #undef NCPFS_PARANOIA
  127. #ifndef DEBUG_NCP
  128. #define DEBUG_NCP 0
  129. #endif
  130. #if DEBUG_NCP > 0
  131. #define DPRINTK(format, args...) printk(format , ## args)
  132. #else
  133. #define DPRINTK(format, args...)
  134. #endif
  135.  
  136. #if DEBUG_NCP > 1
  137. #define DDPRINTK(format, args...) printk(format , ## args)
  138. #else
  139. #define DDPRINTK(format, args...)
  140. #endif
  141.  
  142. /* The readdir cache size controls how many directory entries are
  143.  * cached.
  144.  */
  145. #define NCP_READDIR_CACHE_SIZE        64
  146.  
  147. #define NCP_MAX_RPC_TIMEOUT (6*HZ)
  148.  
  149. /*
  150.  * This is the ncpfs part of the inode structure. This must contain
  151.  * all the information we need to work with an inode after creation.
  152.  * (Move to ncp_fs_i.h once it stabilizes, and add a union in fs.h)
  153.  */
  154. struct ncpfs_i {
  155.     __u32    dirEntNum __attribute__((packed));
  156.     __u32    DosDirNum __attribute__((packed));
  157.     __u32    volNumber __attribute__((packed));
  158.     int    opened;
  159.     int    access;
  160.     __u32    server_file_handle __attribute__((packed));
  161.     __u8    open_create_action __attribute__((packed));
  162.     __u8    file_handle[6] __attribute__((packed));
  163. };
  164.  
  165. /*
  166.  * This is an extension of the nw_file_info structure with
  167.  * the additional information we need to create an inode.
  168.  */
  169. struct ncpfs_inode_info {
  170.     ino_t    ino;        /* dummy inode number */
  171.     struct nw_file_info nw_info;
  172. };
  173.  
  174. /* Guess, what 0x564c is :-) */
  175. #define NCP_SUPER_MAGIC  0x564c
  176.  
  177.  
  178. #define NCP_SBP(sb)          ((struct ncp_server *)((sb)->u.generic_sbp))
  179.  
  180. #define NCP_SERVER(inode)    NCP_SBP((inode)->i_sb)
  181. /* We don't have an ncpfs union yet, so use smbfs ... */
  182. #define NCP_FINFO(inode)     ((struct ncpfs_i *)&((inode)->u.smbfs_i))
  183.  
  184. #ifdef DEBUG_NCP_MALLOC
  185.  
  186. #include <linux/malloc.h>
  187.  
  188. extern int ncp_malloced;
  189. extern int ncp_current_malloced;
  190.  
  191. static inline void *
  192.  ncp_kmalloc(unsigned int size, int priority)
  193. {
  194.     ncp_malloced += 1;
  195.     ncp_current_malloced += 1;
  196.     return kmalloc(size, priority);
  197. }
  198.  
  199. static inline void ncp_kfree_s(void *obj, int size)
  200. {
  201.     ncp_current_malloced -= 1;
  202.     kfree_s(obj, size);
  203. }
  204.  
  205. #else                /* DEBUG_NCP_MALLOC */
  206.  
  207. #define ncp_kmalloc(s,p) kmalloc(s,p)
  208. #define ncp_kfree_s(o,s) kfree_s(o,s)
  209.  
  210. #endif                /* DEBUG_NCP_MALLOC */
  211.  
  212. /* linux/fs/ncpfs/inode.c */
  213. int ncp_notify_change(struct dentry *, struct iattr *attr);
  214. struct super_block *ncp_read_super(struct super_block *, void *, int);
  215. struct inode *ncp_iget(struct super_block *, struct ncpfs_inode_info *);
  216. void ncp_update_inode(struct inode *, struct nw_file_info *);
  217. void ncp_update_inode2(struct inode *, struct nw_file_info *);
  218. extern int init_ncp_fs(void);
  219.  
  220. /* linux/fs/ncpfs/dir.c */
  221. extern struct inode_operations ncp_dir_inode_operations;
  222. int ncp_conn_logged_in(struct ncp_server *);
  223. void ncp_init_dir_cache(void);
  224. void ncp_invalid_dir_cache(struct inode *);
  225. void ncp_free_dir_cache(void);
  226. int ncp_date_dos2unix(__u16 time, __u16 date);
  227. void ncp_date_unix2dos(int unix_date, __u16 * time, __u16 * date);
  228.  
  229. /* linux/fs/ncpfs/ioctl.c */
  230. int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
  231.  
  232. /* linux/fs/ncpfs/sock.c */
  233. int ncp_request(struct ncp_server *server, int function);
  234. int ncp_connect(struct ncp_server *server);
  235. int ncp_disconnect(struct ncp_server *server);
  236. void ncp_lock_server(struct ncp_server *server);
  237. void ncp_unlock_server(struct ncp_server *server);
  238.  
  239. /* linux/fs/ncpfs/file.c */
  240. extern struct inode_operations ncp_file_inode_operations;
  241. int ncp_make_open(struct inode *, int);
  242.  
  243. /* linux/fs/ncpfs/mmap.c */
  244. int ncp_mmap(struct file *, struct vm_area_struct *);
  245.  
  246. /* linux/fs/ncpfs/ncplib_kernel.c */
  247. int ncp_make_closed(struct inode *);
  248.  
  249. static inline void str_upper(char *name)
  250. {
  251.     while (*name) {
  252.         if (*name >= 'a' && *name <= 'z') {
  253.             *name -= ('a' - 'A');
  254.         }
  255.         name++;
  256.     }
  257. }
  258.  
  259. static inline void str_lower(char *name)
  260. {
  261.     while (*name) {
  262.         if (*name >= 'A' && *name <= 'Z') {
  263.             *name += ('a' - 'A');
  264.         }
  265.         name++;
  266.     }
  267. }
  268.  
  269. static inline int ncp_namespace(struct inode *inode)
  270. {
  271.     struct ncp_server *server = NCP_SERVER(inode);
  272.     return server->name_space[NCP_FINFO(inode)->volNumber];
  273. }
  274.  
  275. static inline int ncp_preserve_case(struct inode *i)
  276. {
  277. #if defined(CONFIG_NCPFS_NFS_NS) || defined(CONFIG_NCPFS_OS2_NS)
  278.     int ns = ncp_namespace(i);
  279. #endif
  280.     return
  281. #ifdef CONFIG_NCPFS_OS2_NS
  282.     (ns == NW_NS_OS2) ||
  283. #endif    /* CONFIG_NCPFS_OS2_NS */
  284. #ifdef CONFIG_NCPFS_NFS_NS
  285.     (ns == NW_NS_NFS) ||
  286. #endif    /* CONFIG_NCPFS_NFS_NS */
  287.     0;
  288. }
  289.  
  290. static inline int ncp_case_sensitive(struct inode *i)
  291. {
  292. #ifdef CONFIG_NCPFS_NFS_NS
  293.     return ncp_namespace(i) == NW_NS_NFS;
  294. #else
  295.     return 0;
  296. #endif    /* CONFIG_NCPFS_NFS_NS */
  297.  
  298. #endif                /* __KERNEL__ */
  299.  
  300. #endif                /* _LINUX_NCP_FS_H */
  301.